package com.bbva.kyfb.kyfbjpatlbh.dominiotlbh;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.Id;
import javax.persistence.PersistenceContext;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.dbre.RooDbManaged;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.transaction.annotation.Transactional;

/**
 * The Class Ttlsbclo.
 */
@Configurable
@Entity
@Table(name = "TTLSBCLO",schema = "TLSB")
@RooJavaBean
@RooToString
@RooEntity(versionField = "", persistenceUnit="persistenceUnitTLBH", table = "TTLSBCLO", schema = "TLSB")
@PersistenceContext(unitName="persistenceUnitTLBH")
@RooDbManaged(automaticallyDelete = true)
public class Ttlsbclo {

	@PersistenceContext(unitName="persistenceUnitTLBH")
    transient EntityManager entityManager;


	@Transactional(value="tlbh")
    public void persist() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.persist(this);
    }

	@Transactional(value="tlbh")
    public void remove() {
        if (this.entityManager == null) this.entityManager = entityManager();
        if (this.entityManager.contains(this)) {
            this.entityManager.remove(this);
        } else {
            Ttlsbclo attached = Ttlsbclo.findTtlsbclo(this.codClaseord);
            this.entityManager.remove(attached);
        }
    }

	@Transactional(value="tlbh")
    public void flush() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.flush();
    }

	@Transactional(value="tlbh")
    public void clear() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.clear();
    }

	@Transactional(value="tlbh")
    public Ttlsbclo merge() {
        if (this.entityManager == null) this.entityManager = entityManager();
        Ttlsbclo merged = this.entityManager.merge(this);
        this.entityManager.flush();
        return merged;
    }

	public static final EntityManager entityManager() {
        EntityManager em = new Ttlsbclo().entityManager;
        if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
        return em;
    }

	public static long countTtlsbcloes() {
        return entityManager().createQuery("SELECT COUNT(o) FROM Ttlsbclo o", Long.class).getSingleResult();
    }

	public static List<Ttlsbclo> findAllTtlsbcloes() {
        return entityManager().createQuery("SELECT o FROM Ttlsbclo o", Ttlsbclo.class).getResultList();
    }

	public static Ttlsbclo findTtlsbclo(String codClaseord) {
        if (codClaseord == null || codClaseord.length() == 0) return null;
        return entityManager().find(Ttlsbclo.class, codClaseord);
    }

	public static List<Ttlsbclo> findTtlsbcloEntries(int firstResult, int maxResults) {
        return entityManager().createQuery("SELECT o FROM Ttlsbclo o", Ttlsbclo.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
    }

	public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("AudFmodific: ").append(getAudFmodific()).append(", ");
        sb.append("AudUsuario: ").append(getAudUsuario()).append(", ");
        sb.append("CodClaseord: ").append(getCodClaseord()).append(", ");
        sb.append("CodExtfiche: ").append(getCodExtfiche()).append(", ");
        sb.append("CodPaisfict: ").append(getCodPaisfict()).append(", ");
        sb.append("CodSercrubd: ").append(getCodSercrubd()).append(", ");
        sb.append("CodServimod: ").append(getCodServimod()).append(", ");
        sb.append("CodTipmsje: ").append(getCodTipmsje()).append(", ");
        sb.append("DesClasreme: ").append(getDesClasreme()).append(", ");
        sb.append("HmsCorte: ").append(getHmsCorte()).append(", ");
        sb.append("XtiCorte: ").append(getXtiCorte()).append(", ");
        sb.append("XtiEnvrecep: ").append(getXtiEnvrecep()).append(", ");
        sb.append("XtiModoorde: ").append(getXtiModoorde()).append(", ");
        sb.append("XtiRechazos: ").append(getXtiRechazos()).append(", ");
        sb.append("XtiSubtipor: ").append(getXtiSubtipor()).append(", ");
        sb.append("XtiTipoorde: ").append(getXtiTipoorde()).append(", ");
        sb.append("XtiValidact: ").append(getXtiValidact());
        return sb.toString();
    }


	@Id
    @Column(name = "COD_CLASEORD",columnDefinition = "CHAR", length = 3)
    @NotNull
    private String codClaseord;
	
	@Column(name = "DES_CLASREME",columnDefinition = "CHAR" , length = 20)
    private String desClasreme;

	@Column(name = "COD_SERVIMOD",columnDefinition = "CHAR" , length = 5)
    private String codServimod;

	@Column(name = "AUD_FMODIFIC", columnDefinition = "DATE")
    @NotNull
    @Temporal(TemporalType.DATE)
    @DateTimeFormat(style = "M-")
    private Date audFmodific;

	@Column(name = "AUD_USUARIO",columnDefinition = "CHAR" , length = 8)
    @NotNull
    private String audUsuario;

	@Column(name = "COD_EXTFICHE",columnDefinition = "CHAR" , length = 3)
    private String codExtfiche;

	@Column(name = "XTI_ENVRECEP",columnDefinition = "CHAR", length=1)
    private Character xtiEnvrecep;

	@Column(name = "COD_SERCRUBD")
    private Short codSercrubd;

	@Column(name = "XTI_TIPOORDE",columnDefinition = "CHAR", length=1)
    private Character xtiTipoorde;

	@Column(name = "XTI_SUBTIPOR",columnDefinition = "CHAR", length=1)
    private Character xtiSubtipor;

	@Column(name = "XTI_MODOORDE",columnDefinition = "CHAR", length=1)
    private Character xtiModoorde;

	@Column(name = "XTI_VALIDACT",columnDefinition = "CHAR", length=1)
    private Character xtiValidact;

	@Column(name = "COD_PAISFICT")
    private Short codPaisfict;

	@Column(name = "XTI_CORTE",columnDefinition = "CHAR", length=1)
    private Character xtiCorte;

    @Column(name = "HMS_CORTE",columnDefinition = "TIME")
    @Temporal(TemporalType.DATE)
    //@Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "M-")
    private Date hmsCorte;

	@Column(name = "COD_TIPMSJE",columnDefinition = "CHAR" , length = 4)
    private String codTipmsje;

	@Column(name = "XTI_RECHAZOS",columnDefinition = "CHAR", length=1)
    private Character xtiRechazos;


	public String getCodClaseord() {
        return this.codClaseord;
    }

	public void setCodClaseord(String id) {
        this.codClaseord = id;
    }
	
	public String getDesClasreme() {
        return this.desClasreme;
    }

	public void setDesClasreme(String desClasreme) {
        this.desClasreme = desClasreme;
    }

	public String getCodServimod() {
        return this.codServimod;
    }

	public void setCodServimod(String codServimod) {
        this.codServimod = codServimod;
    }

	public Date getAudFmodific() {
        return this.audFmodific;
    }

	public void setAudFmodific(Date audFmodific) {
        this.audFmodific = audFmodific;
    }

	public String getAudUsuario() {
        return this.audUsuario;
    }

	public void setAudUsuario(String audUsuario) {
        this.audUsuario = audUsuario;
    }

	public String getCodExtfiche() {
        return this.codExtfiche;
    }

	public void setCodExtfiche(String codExtfiche) {
        this.codExtfiche = codExtfiche;
    }

	public Character getXtiEnvrecep() {
        return this.xtiEnvrecep;
    }

	public void setXtiEnvrecep(Character xtiEnvrecep) {
        this.xtiEnvrecep = xtiEnvrecep;
    }

	public Short getCodSercrubd() {
        return this.codSercrubd;
    }

	public void setCodSercrubd(Short codSercrubd) {
        this.codSercrubd = codSercrubd;
    }

	public Character getXtiTipoorde() {
        return this.xtiTipoorde;
    }

	public void setXtiTipoorde(Character xtiTipoorde) {
        this.xtiTipoorde = xtiTipoorde;
    }

	public Character getXtiSubtipor() {
        return this.xtiSubtipor;
    }

	public void setXtiSubtipor(Character xtiSubtipor) {
        this.xtiSubtipor = xtiSubtipor;
    }

	public Character getXtiModoorde() {
        return this.xtiModoorde;
    }

	public void setXtiModoorde(Character xtiModoorde) {
        this.xtiModoorde = xtiModoorde;
    }

	public Character getXtiValidact() {
        return this.xtiValidact;
    }

	public void setXtiValidact(Character xtiValidact) {
        this.xtiValidact = xtiValidact;
    }

	public Short getCodPaisfict() {
        return this.codPaisfict;
    }

	public void setCodPaisfict(Short codPaisfict) {
        this.codPaisfict = codPaisfict;
    }

	public Character getXtiCorte() {
        return this.xtiCorte;
    }

	public void setXtiCorte(Character xtiCorte) {
        this.xtiCorte = xtiCorte;
    }

	public Date getHmsCorte() {
        return this.hmsCorte;
    }

	public void setHmsCorte(Date hmsCorte) {
        this.hmsCorte = hmsCorte;
    }

	public String getCodTipmsje() {
        return this.codTipmsje;
    }

	public void setCodTipmsje(String codTipmsje) {
        this.codTipmsje = codTipmsje;
    }

	public Character getXtiRechazos() {
        return this.xtiRechazos;
    }

	public void setXtiRechazos(Character xtiRechazos) {
        this.xtiRechazos = xtiRechazos;
    }
}
